import React from 'react'
import PropTypes from 'prop-types';
import Router from "next/router";
export default class CaseDetail extends React.Component {
    static getDerivedStateFromProps(nextProps){
        let projectData = nextProps.projectData
        return {
            projectData
        }
    }
    constructor(props) {
        super(props);
        this.state = {

        }
    }
    render() {
        return (
            <ul className='case_detail'>
                {
                    this.state.projectData
                    &&
                    this.state.projectData.map(item => {
                        return (
                            <li className='detail_item' key={item.id} onClick={this.toCaseChild.bind(this,item.id)}>
                                <img className='detail_item_img' src={item.img} alt=""/>
                                <div className='detail_item_info'>
                                    <h2>{item.entry_name}</h2>
                                    <p>{item.customer_name || '暂无详情' }</p>
                                </div>
                            </li>
                        )
                    })
                }
            </ul>
        )
    }
    toCaseChild(id){
        Router.push({pathname:'/case/caseChild', query:{id}})
    }
}

CaseDetail.propTypes = {
    projectData: PropTypes.array
}